#ifndef __MEMORY_H__
#define __MEMORY_H__
#include <cstl/common.h>

/**
* Create and Init global memory pool
* @return {bool} init result
*/
bool memmanager_init();

/**
* Destroy global memory pool
*/
void memmanager_exit();

/**
* Allocate memory through memory pool.
* @param size the memory hope to allocate.
* @return void* memory allocated. if failed return null.
*/
void* cstl_malloc(unsigned int size);

/**
* Free memory through memory pool.
* @param mem memory have allocated by cstl_malloc or malloc
*/
void cstl_free(void* mem);

/**
* Allocate memory and set memory content to zero through memory pool.
* @param size size the memory hope to allocate.
* @return void* memory allocated. if failed return null.
*/
void* cstl_calloc(unsigned int size);

/**
* Dealloc
* @param oldmem
* @param size
* @return
*/
void* cstl_realloc(void* oldmem, unsigned int size);

/**
* Get the memory size really malloc.
*/
size_t cstl_malloc_size(void* mem);

/**
* Get the memory leaks.
*/
size_t cstl_memory_leak();

#endif

